package com.yijiajiao.finance.service.impl;

import com.yijiajiao.finance.bean.AliAccount;
import com.yijiajiao.finance.bean.ResultBean;
import com.yijiajiao.finance.mappers.AliAccountMapper;
import com.yijiajiao.finance.service.AliAccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @AUTHOR zhaoming@eduspace
 * @CREATE 2017-08-10-11:29
 */
@Service
@Slf4j
public class AliAccountServiceImpl implements AliAccountService {

    @Autowired
    private AliAccountMapper aliAccountMapper;

    @Override
    public ResultBean addAccount(AliAccount aliAccount) {
        aliAccountMapper.addAccount(aliAccount);
        log.debug("支付宝账号绑定成功!");
        return ResultBean.getSucResult("支付宝账号绑定成功！");
    }

    @Override
    public ResultBean queryByOpenId(String openId) {
        AliAccount aliAccount = aliAccountMapper.queryByOpenId(openId);
        log.debug("查询到的信息：" + aliAccount);
        return ResultBean.getSucResult(aliAccount);
    }

    @Override
    public ResultBean delByOpenId(String openId) {

        aliAccountMapper.delete( openId );
        log.debug("支付宝账号解绑成功!");
        return ResultBean.getSucResult("支付宝账号解绑成功!");
    }


}
